﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Web.Hosting;
using UDS.Components;

namespace UDS.Entity
{
    /// <summary>
    /// Contains the data of a row in UDS_Position table.
    /// </summary>
    public class PositionInfo
    {
        #region properties
        public int ID
        {
            get;
            set;
        }

        public int ParentPositionID
        {
            get;
            set;
        }

        public string Name
        {
            get;
            set;
        }

        public string Description
        {
            get;
            set;
        }

        public int DepartmentID
        {
            get;
            set;
        }
        #endregion properties

        internal static PositionInfo ReadPositionFromIDataReader(IDataReader dr)
        {
            PositionInfo p = new PositionInfo();
            p.ID = (int)dr["Position_ID"];
            p.ParentPositionID = SQLUtil.ReadInt32(dr["Super_Position_ID"], p.ID);
            p.Name = Convert.ToString(dr["Position_Name"]);
            p.Description = Convert.ToString(dr["Position_Description"]);
            p.DepartmentID = SQLUtil.ReadInt32(dr["Position_ID"], 0);

            return p;
        }
    }
}
